package comxin.demo1.pooldemo;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.mchange.v2.c3p0.DataSources;

import java.sql.Connection;
import java.sql.SQLException;

public class c3p0Utils {
    private static ComboPooledDataSource cpds=new ComboPooledDataSource("intergalactoApp");
    //获取Connection对象
    public static Connection getConncetion() throws SQLException {
        return cpds.getConnection();
    }
    //销毁创建的数据库连接池
    public static void destroy(){
        try {
            DataSources.destroy(cpds);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }


}
